import java.util.Scanner;

class TreeNode{
    public char val1;
    public int val;
    public TreeNode left;
    public TreeNode right;

    public TreeNode(int val) {
        this.val1 = val1;
    }
}

public class TestTree {

    public static int i=0;

    public static TreeNode creatTree(String s){
        TreeNode root=null;
            if (s.charAt(i)!='#'){
                root=new TreeNode(s.charAt(i));
                i++;
                root.left=creatTree(s);
                root.right=creatTree(s);
            }else{
                i++;
            }
        return root;
    }

    public static void inorder(TreeNode root){
        if (root==null){
            return;
        }
        inorder(root.left);
        System.out.print(root.val1+" ");
        inorder(root.right);
    }

    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        while(sc.hasNextLine()){
            String s=sc.nextLine();
            TreeNode root=creatTree(s);
            inorder(root);
        }
    }

}
